<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.wdss.model.*,com.hs.auth.*,java.sql.Clob,com.hs.core.cache.*" pageEncoding="utf-8"%>
<%
	WdssDisinfo obj = (WdssDisinfo)request.getAttribute("obj");
    WdssResource rsobj = (WdssResource)request.getAttribute("rsobj");
   
    List ptomlist = (List)request.getAttribute("ptomlist");
    List discauselist = (List)request.getAttribute("discauselist");
    List cureselect = (List)request.getAttribute("cureselect");
    List symselect = (List)request.getAttribute("symselect"); 
     List preselect = (List)request.getAttribute("preselect"); 
    String dstypevalue = "";
    if(rsobj != null){
    	dstypevalue = rsobj.getDstype() + "";
    }
    boolean typeflag = true;
    if("2".equals(dstypevalue)){
    	typeflag = false;
    }
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../include.jsp"%>  
<script src="<%=basePath %>app/javascripts/transform.js"></script>
<script src='<%=basePath%>dwr/interface/dataProhelper.js'></script>  
<link rel="STYLESHEET" type="text/css" href="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcombo.css"/>
 <script src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcommon.js"></script> 
<script  src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcombo.js"></script> 
<script  src="<%=basePath %>thirtpart/dhtmlx25/ext/dhtmlxcombo_whp.js"></script>  
<script language="javascript" type="text/javascript">
  function downLoadFile(id){
 	window.location.href="<%=basePath%>produce/downloadFile.do?pid="+id;
 } 
 function herbInfo(id){
    window.parent.proresultbasic.frameElement.src = "<%=basePath%>produce/proresultherb.do?preid="+id;
 }
</script>
</head>
<body scroll=yes >
	  <!-- table border="0" cellspacing="0" cellpadding="0" class="news"> 
          <tr>
            <th width="15%">医案来源</th>
            <td colspan=3>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value="1" name="dstype" onclick="changeDstype()" <% if(typeflag) out.print("checked"); %> disabled />书籍&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value="2" name="dstype" onclick="changeDstype()" <% if(!typeflag) out.print("checked"); %> disabled/>期刊
             <input name="resourceid" id="resourceid" type="hidden" value="<%=rsobj==null?"":rsobj.getId()%>"/>
          </tr>
      </table-->
     <div id="book" style="display:<%=typeflag?"":"none" %>">
		 <table border="0" cellspacing="0" cellpadding="0" class="news"> 
	        <caption>
	          医案来源信息（书籍）
	          </caption>
	          <tr>
	            <th width="15%">书名</th>
	            <td width="18%"><%=StringUtilTool.NULL2Blank(rsobj==null?"":rsobj.getBookname()) %> </td>
	            <th width="15%">著者</th>
	            <td ><%=StringUtilTool.NULL2Blank(rsobj==null?"":rsobj.getAuthor()) %></td>
	            <th width="15%">出版社</th>
	            <td width="15%"><%=StringUtilTool.NULL2Blank(rsobj==null?"":rsobj.getPublishunit())%></td>
	          </tr> 
	        </table> 
        </div>
     <div id="period" style="display:<%=typeflag?"none":"" %>">
		 <table border="0" cellspacing="0" cellpadding="0" class="news"> 
	        <caption>
	          医案来源信息（期刊）
	          </caption>
	          <tr>
	            <th width="15%">刊名</th>
	            <td colspan=3><%=StringUtilTool.NULL2Blank(rsobj==null?"":rsobj.getMaganame()) %></td>
	            <th width="15%">题名</th>
	            <td><%=StringUtilTool.NULL2Blank(rsobj==null?"":rsobj.getTitle()) %></td>
	            <th width="15%">作者</th>
	            <td><%=StringUtilTool.NULL2Blank(rsobj==null?"":rsobj.getAuthor())%></td>
	          </tr>
	        </table> 
        </div>
        <table border="0" cellspacing="0" cellpadding="0" class="news"> 
        <caption>
          医案基本信息
          </caption>
          <tr>
            <th width="15%">医案编号</th>
            <td width="18%"><%=obj==null?"":obj.getDiscode() %><input name="wdssid" type="hidden" value="<%=obj.getId()%>"/></td>
            <th  width="15%">病名</th>
            <td width="18%"><%=StringUtilTool.NULL2Blank(obj==null?"":obj.getDisname4view()) %></td>
            <th  width="15%">就诊时间</th>
            <td width="18%"><%=StringUtilTool.NULL2Blank(obj==null?"":obj.getCuredate()) %></td>
          </tr>
          <tr>
            <th>病史</th>
            <td colspan=2><%=StringUtilTool.NULL2Blank(obj==null?"":obj.getDishis()) %></td>
            <th>主述</th>
            <td colspan=2><%=StringUtilTool.NULL2Blank(obj==null?"":obj.getMaindesc()) %></td>
          </tr> 
          <tr>
            <th  width="15%">章节</th>
            <td colspan=2> <%=StringUtilTool.NULL2Blank(obj==null?"":obj.getChapter()) %></td>
            <th  width="15%">页数</th>
            <td colspan=2><%=StringUtilTool.NULL2Blank(obj==null?"":obj.getPagenum()) %></td>
          </tr>
          <tr>
            <th>原文文本</th>
            <td colspan=5 >
            <%
            	if(obj != null){
            		Clob clob = obj.getContent();
            		String contentStr = "";
				    if(clob != null)
				    	contentStr = clob.getSubString(1, (int)clob.length());
				    out.print(contentStr);
            	}
             %>
            </td> 
          </tr>
           <tr>
            <th>已上传附件</th>
            <td colspan=5 >    
            <%
             if(null != obj.getFileset() && !(obj.getFileset().isEmpty())){
                   Iterator iter = obj.getFileset().iterator();
                   int i = 0;  
                   while(iter.hasNext()){
          	             WdssFile fileobj = (WdssFile)iter.next();
          	             i++; 
          	             Long fileid = fileobj.getId();
          	               
           %>
          	<a href="javaScript:downLoadFile('<%=fileid %>')"><%=fileobj.getFilename() %></a>;
          <%} }%>
            </td>
           </tr>
            <tr>
            <th width="15%">并发症</th> 
            <td colspan=2  width="35%">    <font size=3 color=red>
            <%
             if(null != obj.getParaset() && !(obj.getParaset().isEmpty())){
            		 String paracontent = "";
                   Iterator iter = obj.getParaset().iterator();
                   int i = 0;  
                   while(iter.hasNext()){
          	             WdssParainfo paraobj = (WdssParainfo)iter.next();
          	             paracontent = paracontent + paraobj.getParaname() + ";";
          	       }
          	       if(paracontent.endsWith(";")){
          	       		paracontent = paracontent.substring(0,paracontent.length()-1);
          	       }
          	       out.print(paracontent);
          	}
           %></font>
            </td> 
            <th width="15%">病因</th>
            <td colspan=2 >   <font size=3 color=red>  
            <%
             if(null != discauselist && discauselist.size()>0){
	           		for(int j=0; j<discauselist.size(); j++){
	           			Map ptommap = (Map)discauselist.get(j);
	           			String ptype = ptommap.get("datatype").toString();
	           			String ptomtype = ptype + "";
	           			String ptomtypestr = DictCacheUtil.getInst().getCodeNameByCode(ptomtype,"2");
	           			int pos = ptomtypestr.indexOf("-");
	           			if(pos != -1){
	           				ptomtypestr = ptomtypestr.substring(pos+1,ptomtypestr.length());
	           			}
	           			out.print(ptomtypestr+"(");
	           			if(null != obj && !(obj.getDiscauseset().isEmpty())){  
			                   Iterator ptomiter = obj.getDiscauseset().iterator(); 
			                   while(ptomiter.hasNext()){ 
			          	             WdssDiscauseinfo ptom = (WdssDiscauseinfo)ptomiter.next(); 
			          	             Long pid = ptom.getId(); 
			          	             String symtype =  ptom.getDatatype()+"";
			          	             if(ptomtype.equals(symtype)){
			          	             	 String symstr = DictCacheUtil.getInst().getCodeNameByCode(ptom.getCausecode()+"", ptom.getDatatype()+"");
			          	             	out.print("<font color='red'>" +symstr+"</font>;");
			          	             }
			           		   }
	           			}
	           			out.print(")<br/>");
	           		}
	           }
           %></font>
            </td>
           </tr>
            <tr>
            <th width="15%">症状</th>
            <td width="35%" colspan=2 >   
            <%
              if(null != ptomlist && ptomlist.size()>0){
	           		for(int j=0; j<ptomlist.size(); j++){
	           			Map ptommap = (Map)ptomlist.get(j);
	           			String ptype = ptommap.get("symtype").toString();
	           			String ptomtype = ptype + "";
	           			String ptomtypestr = DictCacheUtil.getInst().getCodeNameByCode(ptomtype,"2");
	           			int pos = ptomtypestr.indexOf("-");
	           			if(pos != -1){
	           				ptomtypestr = ptomtypestr.substring(pos+1,ptomtypestr.length());
	           			}
	           			out.print(ptomtypestr+"(");
	           			if(null != obj && !(obj.getPtomset().isEmpty())){  
			                   Iterator ptomiter = obj.getPtomset().iterator(); 
			                   while(ptomiter.hasNext()){ 
			          	             WdssPtominfo ptom = (WdssPtominfo)ptomiter.next(); 
			          	             Long pid = ptom.getId(); 
			          	             String symtype =  ptom.getSymtype()+"";
			          	             if(ptomtype.equals(symtype)){
			          	             	 String symstr = DictCacheUtil.getInst().getCodeNameByCode(ptom.getSymcode()+"", ptom.getSymtype()+"");
			          	             	out.print("<font color='red'>" +symstr+"</font>;");
			          	             }
			           		   }
	           			}
	           			out.print(")<br/>");
	           		}
	           }
           %> 
            </td> 
            <th width="15%">证候</th>
            <td colspan=2 >  <font size=3 color=red>   
            <%
              if(symselect.size()>0){
              	for(int i =0;i<symselect.size();i++){
              		Map data = (Map)symselect.get(i);
              		String id = (String)data.get("ID");
              		String value = (String)data.get("VALUE");
              		out.print(value);
              		out.print(";&nbsp;");
              	}
              }
           %></font>
            </td>
           </tr>
          <tr>
            <th width="15%">治法</th>
            <td colspan=5 > <font size=3 color=red>   
            <%
              if(cureselect.size()>0){
              	for(int i =0;i<cureselect.size();i++){
              		Map data = (Map)cureselect.get(i);
              		String id = (String)data.get("ID");
              		String value = (String)data.get("VALUE");
              		out.print(value);
              		out.print(";&nbsp;");
              	}
              }
           %></font>
            </td>
           </tr>
           
           <tr>
            <th width="15%">方剂</th>
            <td colspan=5 >
            <font size=3 color=red> 
            <%
            	if(preselect.size()>0){
            		for(int i =0;i<preselect.size();i++){
            			Map m = (Map)preselect.get(i);
            		    String prename = (String)m.get("PRENAME");
            		    StringBuffer buffer = new StringBuffer();
            		    buffer.append(prename);
            		    buffer.append("(");
            		    List herblist =  (List)m.get("herblist");
            		    if(herblist.size()==0){
            		    	buffer.append("无)");
            		    }
            		    for(int j=0;j<herblist.size();j++){
            		       Map herb = (Map)herblist.get(j);
            		       String herbname = (String)herb.get("HERBNAME");
            		       String jiliang = (String)herb.get("JILIANG");
            		       String UNITTYPE = (String)herb.get("UNITTYPE");
            		       String METHOD = (String)herb.get("METHOD");
            		       buffer.append(herbname);
            		        buffer.append(";").append(jiliang==null?"":jiliang).append(UNITTYPE==null?"":UNITTYPE);
            		        buffer.append(";").append(METHOD==null?"":METHOD).append("");
             		       if(j != herblist.size()-1){
            		       	  buffer.append(";");
            		       }else{
            		       	  buffer.append(")");
            		       }
            		    }
            		    out.println(buffer.toString());
            		}
            	
            	}
            
            
            
             %>
            
            
            </font>
            
           
            </td>
           </tr>
        </table> 
      
</body>
</html>



